from sqlalchemy import Column, BigInteger, String, DateTime, LargeBinary
from sqlalchemy.sql import func
from app.db.database import Base

class File(Base):
    __tablename__ = "file"

    id        = Column(BigInteger, primary_key=True, autoincrement=True)
    biz_type  = Column(String(16), nullable=False, comment="SPOT_COVER / SPOT_VIDEO / AVATAR ...")
    biz_id    = Column(BigInteger, nullable=False, comment="业务主键")
    url       = Column(String(255), nullable=False, comment="外部访问路径 /api/files/{id}")
    blob_data = Column(LargeBinary(length=(2**32 - 1)), nullable=False, comment="文件二进制")
    created_at = Column(DateTime, server_default=func.now())